#ifndef     __FRIDGE_H
#define     __FRIDGE_H

#include "../utils/no_copyable.h"
#include "../utils/object.h"
#include "../utils/motor_ctrl.h"
#include "../utils/error.h"

namespace driver {

class Fridge : utils::no_copyable_t, 
    public utils::MotorCtrl<Fridge, 100, 25, 100, 15 * 1000> 
{
public:
    enum dir_t {
        Open = 0,
        Close = 1,
        Brake = 2,
    };

    Fridge();

    utils::error_t open(uint16_t speed);
    utils::error_t close(uint16_t speed);
    utils::error_t open();
    utils::error_t close();
    
    static void set_target_speed(uint16_t speed);
    static uint16_t get_target_speed();

    static void set_voltage(uint16_t val);
    static uint16_t get_count();

private:
    static void reset_count();
    static void set_dir(dir_t dir);
};

inline utils::object_t<Fridge> fridge;

}


#endif
